#include<stdio.h>
#include<stdlib.h>

 int a=0,b=1,c=2;
 int d,e,f;

void Printspace(char* env[])
{
  int* pi1=malloc(10);
  int* pi2=malloc(20);
  int* pi3=malloc(30);
  int g=0,k=0,z=2;
  const char* str="hello Linux";
  printf("第一组变量验证：栈区是向下伸展的\n");
  printf("stack:%p\n",&g);
  printf("stack:%p\n",&k);
  printf("stack:%p\n",&z);
  printf("第二组变量验证：堆区是向上伸展的\n");
  printf("heap:%p\n",pi1);
  printf("heap:%p\n",pi2);
  printf("heap:%p\n",pi3);
  printf("第三组变量验证：字符常量区\n");
  printf("String:%p\n",str);
  printf("第四组变量验证：环境变量\n");
  printf("environ:%p\n",env[0]);
  printf("environ:%p\n",env[1]);
  printf("environ:%p\n",env[2]);
  printf("environ:%p\n",env[3]);
  printf("环境变量有很多，此处未全部打印\n");
  printf("第五组变量验证：Bss段\n");
  printf("Bss:%p\n",&d);
  printf("Bss:%p\n",&e);
  printf("Bss:%p\n",&f);
  printf("第六组变量验证：数据段\n");
  printf("数据段：%p\n",&a);
  printf("数据段：%p\n",&b);
  printf("数据段：%p\n",&c);
}
int main(int argc,char* argv[],char* env[])
{
  Printspace(env);
  return 0;
}


